<?php
require '../com.swiss.mooh.dao.impl/ImageContentDaoImpl.php';
require '../com.swiss.mooh.service/ImageContentServiceImpl.php';


$dispatcher = new ImageContentDaoImpl();
$imageContentService = new ImageContentServiceImpl($dispatcher);

$output_dir = "../../assets/images/uploads/images/";

$imageName = $_POST['imageName'];
$descID = $_POST['descID'];
$filePath = $output_dir . $imageName;
if (file_exists($filePath)) {
    unlink($filePath);
    $result = $imageContentService->deleteImageContentByID($imageName);
    if ($result == 200) {
        $listOfFileVO = $imageContentService->getAllImageContentByDescID($descID);
        for ($i = 0; $i < $listOfFileVO->Size(); $i++) {
            ?>
            <a href="#" class="list-group-item">   
                <span class="badge" onclick="getLink('http://localhost/SwissMoohBackEnd/assets/images/uploads/images/<?= $listOfFileVO->GetObj($i)->getImageName(); ?>')"><i class="fa fa-link"></i></span>
                <span class="badge" onclick="deleteImageByName2('<?= $listOfFileVO->GetObj($i)->getImageName(); ?>', '<?= $descID ?>')"><i class="fa fa-trash"></i></span>
                <span>
                    <span class="fancies fancybox-effects-d" href="http://localhost/SwissMoohBackEnd/assets/images/uploads/images/<?= $listOfFileVO->GetObj($i)->getImageName(); ?>" title="<?= $listOfFileVO->GetObj($i)->getImageName(); ?>">
                        <i class="fa fa-fw fa-calendar"></i><?= $listOfFileVO->GetObj($i)->getImageName(); ?>
                    </span>
                </span>
            </a>
            <?php
        }
    } else {
        echo $result;
    }
}
